package myUtils;

/**
 * 响应格式规范
 */
public class Response {
	    //存放响应信息
	    private String message="";
	    //存放响应结果,SUCCESS or FAIL
	    private String status;
	    //存放数据主体
	    private Object data=null;
	    private Object metedata=null;
	    
		public static final String SUCCESS = "200";
	    public static final String FAIL = "500";
	    
	    public Response(String status,String message){
	        this.message = message;
	        this.status = status;
	    }
	    
	    public Response(String status,String message,Object data){
	        this.message = message;
	        this.status = status;
	        this.data = data;
	    }
	    
	    public Response(String status,String message,Object data,Object metedata){
	        this.message = message;
	        this.status = status;
	        this.data = data;
	        this.metedata = metedata;
	    }

	    public String getMessage() {
	        return message;
	    }

	    public void setMessage(String message) {
	        this.message = message;
	    }

	    public Object getData() {
	        return data;
	    }

	    public void setData(Object object) {
	        this.data = object;
	    }

	    public String getStatus() {
	        return status;
	    }

	    public void setStatus(String status) {
	        this.status = status;
	    }
	    
	    public Object getMetedata() {
			return metedata;
		}

		public void setMetedata(Object metedata) {
			this.metedata = metedata;
		}
		
	    public static Response successWrap() {
	    	return new Response(Response.SUCCESS, "请求成功");
	    }
	    
	    public static Response successWrap(Object data) {
	    	return new Response(Response.SUCCESS, "", data);
	    }
	    
	    public static Response successWrap(Object data,Object metedata) {
	    	return new Response(Response.SUCCESS, "", data, metedata);
	    }
	    
	    public static Response failWrap(String msg,Object data) {
	    	return new Response(Response.FAIL, msg, data);
	    }
	    
	    public static Response failWrap(String msg) {
	    	return new Response(Response.FAIL, msg);
	    }
	    
}
